package com.mezz.bones.bff.app.adapter.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mezz.bones.framework.base.domain.response.Result;
import com.mezz.bones.user.application.domain.cmd.SysMenuCreateCmd;
import com.mezz.bones.user.application.domain.cmd.SysMenuDeleteCmd;
import com.mezz.bones.user.application.domain.cmd.SysMenuUpdateCmd;
import com.mezz.bones.user.application.domain.qry.SysMenuPageForAppQry;
import com.mezz.bones.user.application.domain.res.SysMenuDetailForAppResponse;
import com.mezz.bones.user.application.domain.res.SysMenuPageForAppResponse;
import com.mezz.bones.user.application.executor.cmd.ISysMenuExecutor;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: mezz
 * @Date: 2025/1/15 19:02
 * @Description: 菜单信息管理
 * @Version: 1.0
 **/

@RestController
@RequestMapping("/app/menu")
@Api("菜单信息管理")
@AllArgsConstructor
public class MenuController {

    private final ISysMenuExecutor sysMenuExecutor;

    @PostMapping("/create")
    @ApiOperation("菜单-新增")
    public Result<String> create(@RequestBody SysMenuCreateCmd cmd) {
        sysMenuExecutor.execSysMenuCreateCmd(cmd);
        return Result.OK();
    }

    @PostMapping("/update")
    @ApiOperation("菜单-修改")
    public Result<String> update(@RequestBody SysMenuUpdateCmd cmd) {
        sysMenuExecutor.execSysMenuUpdateCmd(cmd);
        return Result.OK();
    }

    @PostMapping("/delete")
    @ApiOperation("菜单-删除")
    public Result<String> delete(@RequestBody SysMenuDeleteCmd cmd) {
        sysMenuExecutor.execSysMenuDeleteCmd(cmd);
        return Result.OK();
    }

    @GetMapping("/detail/{id}")
    @ApiOperation("菜单-详情")
    public Result<SysMenuDetailForAppResponse> detail(@PathVariable("id") String id) {
        return Result.OK(sysMenuExecutor.detailForApp(id));
    }

    @GetMapping("/page")
    @ApiOperation("菜单-列表-分页")
    public Result<Page<SysMenuPageForAppResponse>> page(SysMenuPageForAppQry qry) {
        return Result.OK(sysMenuExecutor.pageForApp(qry));
    }
}